<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Category_model extends CI_Model {

	/**
	 * 添加栏目
	 * @param  [type] $data [description]
	 * @return [type]       [description]
	 */
	public function insert($data) {
		$cid = $this->db->insert('category', $data);
		return $cid;
	}

	/**
	 * 获取栏目列表
	 */
	public function get_category() {
		$data = $this->db->get('category')->result_array();
		return $data;
	}

	/**
	 * 获取单个栏目
	 * @param  [type] $cid [description]
	 * @return [type]      [description]
	 */
	public function get_cate($cid) {
		$data = $this->db->from('category')
					 ->where(array('cid'=>$cid))
					 ->get()
					 ->row_array();
		return $data;
	}
	/**
	 * 修改栏目
	 * @param  [type] $cid  [栏目ID]
	 * @param  [type] $data [description]
	 */
	public function update($cid, $data) {
		$this->db->update('category', $data, array('cid'=>$cid));
	}

	public function del($cid) {
		 $this->db->delete('category', array('cid'=>$cid));
	}

}

/* End of file category_model.php */
/* Location: ./application/models/category_model.php */